package com.tamtamy.jtta.data.json;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import com.tamtamy.jtta.data.ContentList;
import com.tamtamy.jtta.exception.NoResultException;

public class JSONContentList extends ContentList {
	
	private static final long serialVersionUID = 3192226479623273814L;

	public JSONContentList(JSONObject jsonObject) throws NoResultException{
		super();
		JSONArray contentListJSON = (JSONArray)jsonObject.get("list");
		if (contentListJSON == null || contentListJSON.size()==0){
			throw new NoResultException("No comments found");
		}
		for (int i = 0; i < contentListJSON.size(); i++) {
			JSONObject contentJSON = contentListJSON.getJSONObject(i);
			this.add(new JSONContent(contentJSON));
		}	
	}
}
